/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "pharmacyproduct")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pharmacyproduct.findAll", query = "SELECT p FROM Pharmacyproduct p"),
    @NamedQuery(name = "Pharmacyproduct.findByPharmacyId", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.pharmacyId = :pharmacyId"),
    @NamedQuery(name = "Pharmacyproduct.findByPharmacyIdByActive", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.pharmacyId = :pharmacyId AND p.active = :active"),
    @NamedQuery(name = "Pharmacyproduct.findByPharmacyIdByProviderIdByProductId", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.pharmacyId = :pharmacyId AND p.pharmacyproductPK.providerId = :providerId AND p.pharmacyproductPK.productId = :productId"),
    @NamedQuery(name = "Pharmacyproduct.findByProviderId", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.providerId = :providerId"),
    @NamedQuery(name = "Pharmacyproduct.findByProviderIdByActive", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.providerId = :providerId AND p.active = :active"),
    @NamedQuery(name = "Pharmacyproduct.findByProductId", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.productId = :productId"),
    @NamedQuery(name = "Pharmacyproduct.findByProductIdByActive", query = "SELECT p FROM Pharmacyproduct p WHERE p.pharmacyproductPK.productId = :productId AND p.active = :active"),
    @NamedQuery(name = "Pharmacyproduct.findByRepositionLevel", query = "SELECT p FROM Pharmacyproduct p WHERE p.repositionLevel = :repositionLevel"),
    @NamedQuery(name = "Pharmacyproduct.findBySurplusLevel", query = "SELECT p FROM Pharmacyproduct p WHERE p.surplusLevel = :surplusLevel"),
    @NamedQuery(name = "Pharmacyproduct.findByPackage1", query = "SELECT p FROM Pharmacyproduct p WHERE p.package1 = :package1"),
    @NamedQuery(name = "Pharmacyproduct.findByCost", query = "SELECT p FROM Pharmacyproduct p WHERE p.cost = :cost"),
    @NamedQuery(name = "Pharmacyproduct.findByLocation", query = "SELECT p FROM Pharmacyproduct p WHERE p.location = :location"),
    @NamedQuery(name = "Pharmacyproduct.findByService", query = "SELECT p FROM Pharmacyproduct p WHERE p.service = :service"),
    @NamedQuery(name = "Pharmacyproduct.findByRequiresPrescription", query = "SELECT p FROM Pharmacyproduct p WHERE p.requiresPrescription = :requiresPrescription"),
    @NamedQuery(name = "Pharmacyproduct.findByHaveExpirationDate", query = "SELECT p FROM Pharmacyproduct p WHERE p.haveExpirationDate = :haveExpirationDate"),
    @NamedQuery(name = "Pharmacyproduct.findByActive", query = "SELECT p FROM Pharmacyproduct p WHERE p.active = :active")})
public class Pharmacyproduct implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PharmacyproductPK pharmacyproductPK;
    @Basic(optional = false)
    @Column(name = "repositionLevel")
    private short repositionLevel;
    @Column(name = "surplusLevel")
    private Short surplusLevel;
    @Basic(optional = false)
    @Column(name = "package")
    private boolean package1;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cost")
    private Double cost;
    @Column(name = "location")
    private String location;
    @Basic(optional = false)
    @Column(name = "service")
    private boolean service;
    @Basic(optional = false)
    @Column(name = "requiresPrescription")
    private boolean requiresPrescription;
    @Basic(optional = false)
    @Column(name = "haveExpirationDate")
    private boolean haveExpirationDate;
    
    @Column(name = "valueTempCountItem")
    private short valueTempCountItem;
    @Column(name = "valueTempCountPackage")
    private short valueTempCountPackage;    
    @Column(name = "valueTempStockId")
    private short valueTempStockId;
    @Column(name = "valueDiscount")
    private Double valueDiscount;
    @Column(name = "valueBonus")
    private short valueBonus;

	@Basic(optional = false)
    @Column(name = "active")
    private boolean active;
    @OneToMany(mappedBy = "pharmacyproduct")
    private Collection<Package> packageCollection;
    @JoinColumn(name = "pharmacyId", referencedColumnName = "pharmacyId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Pharmacy pharmacy;
    /*
    @JoinColumns({
        @JoinColumn(name = "providerId", referencedColumnName = "providerId", insertable = false, updatable = false),
        @JoinColumn(name = "productId", referencedColumnName = "productId", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Product product;
	*/
    @JoinColumns({
        @JoinColumn(name = "providerId", referencedColumnName = "providerId", insertable = false, updatable = false),
        @JoinColumn(name = "productId", referencedColumnName = "productId", insertable = false, updatable = false)})
    @OneToOne(optional = false)
    private Product product;
    
    public Pharmacyproduct() {
        this.packageCollection = new ArrayList<Package>();
    }

    public Pharmacyproduct(PharmacyproductPK pharmacyproductPK) {
        this.pharmacyproductPK = pharmacyproductPK;
        this.packageCollection = new ArrayList<Package>();
    }

    public Pharmacyproduct(PharmacyproductPK pharmacyproductPK, short repositionLevel, boolean package1, boolean service, boolean requiresPrescription, boolean haveExpirationDate, boolean active) {
        this.pharmacyproductPK = pharmacyproductPK;
        this.repositionLevel = repositionLevel;
        this.package1 = package1;
        this.service = service;
        this.requiresPrescription = requiresPrescription;
        this.haveExpirationDate = haveExpirationDate;
        this.active = active;
        this.packageCollection = new ArrayList<Package>();
    }

    public Pharmacyproduct(int pharmacyId, int providerId, int productId) {
        this.pharmacyproductPK = new PharmacyproductPK(pharmacyId, providerId, productId);
        this.packageCollection = new ArrayList<Package>();
    }

    public PharmacyproductPK getPharmacyproductPK() {
        return pharmacyproductPK;
    }

    public void setPharmacyproductPK(PharmacyproductPK pharmacyproductPK) {
        this.pharmacyproductPK = pharmacyproductPK;
    }

    public short getRepositionLevel() {
        return repositionLevel;
    }

    public void setRepositionLevel(short repositionLevel) {
        this.repositionLevel = repositionLevel;
    }

    public Short getSurplusLevel() {
        return surplusLevel;
    }

    public void setSurplusLevel(Short surplusLevel) {
        this.surplusLevel = surplusLevel;
    }

    public boolean getPackage1() {
        return package1;
    }

    public void setPackage1(boolean package1) {
        this.package1 = package1;
    }

    public Double getCost() {
        return cost;
    }

    public void setCost(Double cost) {
        this.cost = cost;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public boolean getService() {
        return service;
    }

    public void setService(boolean service) {
        this.service = service;
    }

    public boolean getRequiresPrescription() {
        return requiresPrescription;
    }

    public void setRequiresPrescription(boolean requiresPrescription) {
        this.requiresPrescription = requiresPrescription;
    }

    public boolean getHaveExpirationDate() {
        return haveExpirationDate;
    }

    public void setHaveExpirationDate(boolean haveExpirationDate) {
        this.haveExpirationDate = haveExpirationDate;
    }

    public short getValueTempCountItem() {
		return valueTempCountItem;
	}

	public void setValueTempCountItem(short valueTempCountItem) {
		this.valueTempCountItem = valueTempCountItem;
	}

	public short getValueTempCountPackage() {
		return valueTempCountPackage;
	}

	public void setValueTempCountPackage(short valueTempCountPackage) {
		this.valueTempCountPackage = valueTempCountPackage;
	}

	public short getValueTempStockId() {
		return valueTempStockId;
	}

	public void setValueTempStockId(short valueTempStockId) {
		this.valueTempStockId = valueTempStockId;
	}
    
	public Double getValueDiscount() {
		return valueDiscount;
	}

	public void setValueDiscount(Double valueDiscount) {
		this.valueDiscount = valueDiscount;
	}

	public short getValueBonus() {
		return valueBonus;
	}

	public void setValueBonus(short valueBonus) {
		this.valueBonus = valueBonus;
	}
	
    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    //@XmlTransient
    public Collection<Package> getPackageCollection() {
        return packageCollection;
    }

    public void setPackageCollection(Collection<Package> packageCollection) {
        this.packageCollection = packageCollection;
    }

    public Pharmacy getPharmacy() {
        return pharmacy;
    }

    public void setPharmacy(Pharmacy pharmacy) {
        this.pharmacy = pharmacy;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pharmacyproductPK != null ? pharmacyproductPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pharmacyproduct)) {
            return false;
        }
        Pharmacyproduct other = (Pharmacyproduct) object;
        if ((this.pharmacyproductPK == null && other.pharmacyproductPK != null) || (this.pharmacyproductPK != null && !this.pharmacyproductPK.equals(other.pharmacyproductPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Pharmacyproduct[ pharmacyproductPK=" + pharmacyproductPK + " ]";
    }
    
}
